<?php

abstract class Http implements ArrayAccess {
	public static $POST;
	public static $GET;
	public static $ANY;
  public final function offsetSet($offset, $value) {	throw new Exception('Http arrays are readonly.'); }
	public final function offsetUnset($offset) { throw new Exception('Http arrays are readonly.'); }
}

final class HttpPost extends Http { 
	public final function offsetExists($offset) { return isset($_POST[$offset]); }
	public function offsetGet($offset) { return isset($_POST[$offset]) ? new HttpValue($_POST[$offset]) : new HttpValue(null); }
}
final class HttpGet extends Http { 
	public final function offsetExists($offset) { return isset($_GET[$offset]); }
	public function offsetGet($offset) { return isset($_GET[$offset]) ? new HttpValue($_GET[$offset]) : new HttpValue(null); } 
}
final class HttpAny extends Http {
	public final function offsetExists($offset) { return isset($_GET[$offset]) || isset($_POST[$offset]); }
	public function offsetGet($offset) { 
		$a = Http::$GET[$offset]->AsString();
		$b = Http::$POST[$offset]->AsString();
		$v = null; if (!is_null($a) && !is_null($b)) $v = $a.','.$b;	elseif (!is_null($a)) $v = $a; elseif (!is_null($b)) $v = $b;
		return new HttpValue($v);
	}
}
Http::$POST = new HttpPost();
Http::$GET = new HttpGet();
Http::$ANY = new HttpAny();
?>